import 'slugger.dart';
import 'remote_callable.dart';
import 'web.dart';

enum ChannelType { Web, Slugger, WebSocket }

class Channels {
  static Map<ChannelType, RemoteCallable> _sharedChannels = Map();

  static T shared<T extends RemoteCallable>(ChannelType type) {
    var channel = _sharedChannels[type];
    if (channel != null) {
      return channel;
    }
    if (type == ChannelType.Slugger) {
      channel = SluggerChannel();
    } else if (type == ChannelType.Web) {
      channel = WebChannel();
    }
    _sharedChannels[type] = channel;
    return channel;
  }
}
